﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ExamScoreView.aspx.cs" Inherits="Credit_Teacher_ScoreInput_luofang_ExamScoreView" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>期末成绩录入</title>
    <link href="../../../Common/css/main.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../../../Common/js/jquery.js"></script>
    <script type="text/javascript" src="../../../Common/js/common.js"></script>
    <script type="text/javascript" src="../../../Common/js/msg.js"></script>  
    <script type="text/javascript">
    var subjIdList = new Array();
    var subjNameList = new Array();
    var arrayStuIds = new Array();
    var stuNumbers = new Array();
    var stuNames = new Array();
    var exams = new Array();
    var clsName="";
    var examid;
    var eexam;
    var classType;
    var classId;
    var Grade;
    //罗芳。纳入学分的期末成绩上限为100
    var luofangScoreMax = 100;
  
    function GetExcel()
    {
        var settingTable = document.getElementById('settingTable');

        var scoreArray = new Array();

        for(i=1;i<settingTable.rows.length;i++)
        {
            arrayStuIds[i-1] = settingTable.rows[i].id;
            for(j=0;j<subjIdList.length;j++)
            {
                var temScore = settingTable.rows[i].getAttribute("subject"+subjIdList[j]);
                scoreArray[(i-1)*subjIdList.length+j] = (temScore=="null")? -1:temScore;
            }
            stuNumbers[i-1] = settingTable.rows[i].cells[0].innerText;
            stuNames[i-1] = settingTable.rows[i].cells[1].innerText;
        }
        
        PageMethods.GetExcel(stuNumbers,stuNames,subjIdList,subjNameList,scoreArray,classId,function(result){
            if(result!="")
            {

                document.getElementById("downloadFrame").src = "xml_download.aspx?path="+result;
            //    window.open("xls_files/"+result);
            }
            else
                showMassgeBox("提示","服务器正忙请重试！",2,null);
        },function(err){showMassgeBox("提示",err._message,1,null);});
    }
  
    function MyClosePopForm(value)
    {
        ClosePopForm('upInputPop');
        if(!value)
        {
            showMassgeBox("提示","有成绩大于100无法导入！",1,null);
        }
        
    }

    //检测输入的excel是不是符合要求
    function CheckV(frame)
    {
        if(frame.length<3 || frame.length != 3+subjNameList.length)
        {
            return false;
        }
        if( frame[1] != "学号" || frame[2] != "姓名")//clsName+"成绩导入" != frame[0] ||
        {
            return false;
        } 
        for(i=0;i<subjNameList.length;i++)
        {
            if(subjNameList[i] != frame[3+i])
            {
                return false;
            } 
        }
        return true;
    }
    
    function ShowError(msg)
    {
        showMassgeBox("提示",msg,2,null);
    }

    
    function GetStuScore(sall,sid)
    {
        for(iii=0;iii<sall.length;iii++)
        {
            if(sall[iii].StudentID == sid)
            {
                return sall[iii];
            }
        }
        return null;
    }
    
</script>
</head>
<body scroll=auto>
    <form id="form1" runat="server">

        <div class="mainWarp" style="padding-top:2px;height: 88%; overflow: auto; padding-top:5px;">
            <div class="pageBody">
                <div>
                    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
                    </asp:ScriptManager>
                </div>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        <div>
                             <h4><%= title %> </h4>
                             <a onclick="GetExcel()"><u>下载成绩</u></a>
                        </div>
                        <asp:Repeater ID="Repeater1" runat="server">
                            <HeaderTemplate>
                                <table id="settingTable" border="0" cellpadding="0" cellspacing="1"  style="width:320px;" class="useList">
                                    <tr  >
                                        <%= GetHeader()%>
                                    </tr>
                            </HeaderTemplate>
                            <ItemTemplate>
                                
                                    <%# GetStudent((int)Eval("RID"), Eval("StudentCode").ToString(), Eval("StudentName").ToString())%>
                                
                            </ItemTemplate>
                            <FooterTemplate>
                                </table>
                            </FooterTemplate>
                        </asp:Repeater>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="btnBind" EventName="Click" />
                    </Triggers>
                </asp:UpdatePanel>
                <div style="display: none;">
                <input id="Text2" type="text" />
                  <asp:Button ID="btnBind" runat="server" OnClick="btnBind_Click" Text="btnBind" />
                  <iframe src="" name="ifram" id="downloadFrame" style="height: 80%;width: 95%;overflow-y:auto;overflow-x:none;" frameborder="0"   ></iframe>
                </div>

            </div>
        </div>

    <div id="upInputPop" class="layoutWarp" style="display: none; width:380px;height:230px;">
         <div class="title" >
	        <span id="upInputPopTitle"></span>
            <a title="关闭" onclick="return ClosePopForm('upInputPop')">关闭</a>
               
          </div>
        <iframe src="upload.aspx" name="ifram" id="uploadf" style="height: 80%;width: 95%;overflow-y:auto;overflow-x:none;" frameborder="0"   ></iframe>
    </div>
    

   </form>
</body>
</html>
<script language="javascript">
    <%
        int i = 0;

        Response.Write("subjIdList[0] ="+cause.RID+";");
        Response.Write("subjNameList[0] ='"+cause.CauseName+"';");

        Response.Write("classId=" +  cls.RID +";");

        Response.Write("clsName='"+cls.ClsName+"';");

        for(i=0;i<studentInfo.Count;i++)
        {
            Response.Write("arrayStuIds["+i+"]=" +  studentInfo[i].RID +";");
            Response.Write("stuNumbers["+i+"]='" +  studentInfo[i].StudentCode +"';");
            Response.Write("stuNames["+i+"]='" +  studentInfo[i].StudentName +"';");
        }
 
     %>

</script>